import 'login_post_info.dart';
import 'uias_role_list.dart';
import 'user_org_post_dto_list.dart';

class UserInfo {
  String? userId;
  String? userName;
  String? loginName;
  dynamic loginType;
  dynamic headUrl;
  String? token;
  DateTime? loginTime;
  int? expiresMillisecond;
  String? tenantId;
  String? appId;
  String? appCode;
  int? userType;
  dynamic checkedIdentity;
  List<UiasRoleList>? uiasRoleList;
  dynamic menuIds;
  List<String>? appCodes;
  List<UserOrgPostDtoList>? userOrgPostDtoList;
  dynamic permissionMenus;
  dynamic permissionMenuDtos;
  LoginPostInfo? loginPostInfo;
  dynamic roleVoList;
  dynamic defaultPlatform;
  dynamic sessionKey;
  dynamic openId;
  dynamic headImgUrl;
  dynamic nickName;

  UserInfo({
    this.userId,
    this.userName,
    this.loginName,
    this.loginType,
    this.headUrl,
    this.token,
    this.loginTime,
    this.expiresMillisecond,
    this.tenantId,
    this.appId,
    this.appCode,
    this.userType,
    this.checkedIdentity,
    this.uiasRoleList,
    this.menuIds,
    this.appCodes,
    this.userOrgPostDtoList,
    this.permissionMenus,
    this.permissionMenuDtos,
    this.loginPostInfo,
    this.roleVoList,
    this.defaultPlatform,
    this.sessionKey,
    this.openId,
    this.headImgUrl,
    this.nickName,
  });

  factory UserInfo.fromJson(Map<String, dynamic> json) => UserInfo(
        userId: json['userId'] as String?,
        userName: json['userName'] as String?,
        loginName: json['loginName'] as String?,
        loginType: json['loginType'] as dynamic,
        headUrl: json['headUrl'] as dynamic,
        token: json['token'] as String?,
        loginTime: json['loginTime'] == null
            ? null
            : DateTime.parse(json['loginTime'] as String),
        expiresMillisecond: json['expiresMillisecond'] as int?,
        tenantId: json['tenantId'] as String?,
        appId: json['appId'] as String?,
        appCode: json['appCode'] as String?,
        userType: json['userType'] as int?,
        checkedIdentity: json['checkedIdentity'] as dynamic,
        uiasRoleList: (json['uiasRoleList'] as List<dynamic>?)
            ?.map((e) => UiasRoleList.fromJson(e as Map<String, dynamic>))
            .toList(),
        menuIds: json['menuIds'] as dynamic,
        appCodes: json['appCodes'].cast<String>(),
        userOrgPostDtoList: (json['userOrgPostDTOList'] as List<dynamic>?)
            ?.map((e) => UserOrgPostDtoList.fromJson(e as Map<String, dynamic>))
            .toList(),
        permissionMenus: json['permissionMenus'] as dynamic,
        permissionMenuDtos: json['permissionMenuDTOS'] as dynamic,
        loginPostInfo: json['loginPostInfo'] == null
            ? null
            : LoginPostInfo.fromJson(
                json['loginPostInfo'] as Map<String, dynamic>),
        roleVoList: json['roleVOList'] as dynamic,
        defaultPlatform: json['defaultPlatform'] as dynamic,
        sessionKey: json['sessionKey'] as dynamic,
        openId: json['openId'] as dynamic,
        headImgUrl: json['headImgUrl'] as dynamic,
        nickName: json['nickName'] as dynamic,
      );

  Map<String, dynamic> toJson() => {
        'userId': userId,
        'userName': userName,
        'loginName': loginName,
        'loginType': loginType,
        'headUrl': headUrl,
        'token': token,
        'loginTime': loginTime?.toIso8601String(),
        'expiresMillisecond': expiresMillisecond,
        'tenantId': tenantId,
        'appId': appId,
        'appCode': appCode,
        'userType': userType,
        'checkedIdentity': checkedIdentity,
        'uiasRoleList': uiasRoleList?.map((e) => e.toJson()).toList(),
        'menuIds': menuIds,
        'appCodes': appCodes,
        'userOrgPostDTOList':
            userOrgPostDtoList?.map((e) => e.toJson()).toList(),
        'permissionMenus': permissionMenus,
        'permissionMenuDTOS': permissionMenuDtos,
        'loginPostInfo': loginPostInfo?.toJson(),
        'roleVOList': roleVoList,
        'defaultPlatform': defaultPlatform,
        'sessionKey': sessionKey,
        'openId': openId,
        'headImgUrl': headImgUrl,
        'nickName': nickName,
      };
}
